package com.ylzinfo.channelclient.remote;

import com.github.lianjiatech.retrofit.spring.boot.core.RetrofitClient;
import com.github.lianjiatech.retrofit.spring.boot.degrade.sentinel.SentinelDegrade;
import com.github.lianjiatech.retrofit.spring.boot.log.LogLevel;
import com.github.lianjiatech.retrofit.spring.boot.log.LogStrategy;
import com.github.lianjiatech.retrofit.spring.boot.log.Logging;
import com.ylzinfo.channelclient.exception.AppBizException;
import com.ylzinfo.channelclient.model.req.ObtainH5PageReq;
import com.ylzinfo.channelclient.model.req.ObtainH5TokenReq;
import com.ylzinfo.channelclient.model.resp.BaseH5Response;
import com.ylzinfo.channelclient.model.resp.ObtainH5ChannelTokenResp;
import com.ylzinfo.channelclient.model.resp.ObtainH5PageResp;
import com.ylzinfo.channelclient.remote.fallback.GgfwApiFallbackFactory;
import org.springframework.stereotype.Component;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;

/**
 *
 * http交互
 * @author zengjw
 */
@RetrofitClient(baseUrl = "${ggfw.url}",
        fallbackFactory = GgfwApiFallbackFactory.class
)
@Logging(logStrategy = LogStrategy.BODY,logLevel = LogLevel.DEBUG)
//降级规则5s内瓶颈响应时间超过500ms触发降级 基于线程数进行限流
@SentinelDegrade(enable = true,count = 4500,timeWindow = 15,grade = 0)
public interface GgfwFeign {

    /**
     * 获取用户令牌
     * @param request
     * @return
     */
    @POST("h5Service/obtainToken")
    Call<BaseH5Response<ObtainH5ChannelTokenResp>> obtainToken(@Body ObtainH5TokenReq request);

    /**
     * 获取页面地址
     * @param request
     * @return
     */
    @POST("h5Service/obtainH5Page")
    Call<BaseH5Response<ObtainH5PageResp>> obtainH5Page(@Body ObtainH5PageReq request);

}
